package com.example.demo;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * Copyfright(C),2022-2022,复兴元宇科技有限公司
 * FileName:MyCustomConstraintValidator
 * Author:yz
 * Date:2022/3/14 7:49 下午
 * Description:
 * History:
 * <author>  <time> <version> <desc>
 * 作者       时间    版本      描述
 */
public class MyCustomConstraintValidator implements ConstraintValidator<MyCustomConstraint, String> {
    @Override
    public void initialize(MyCustomConstraint myCustomConstraint) {
        //在启动时执行
    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext validatorContext) {
        if (!(s.equals("北京") || s.equals("上海"))) {
            return false;
        }
        return true;
    }
}
